import React from "react";
import { BotVipSd } from "@/components/main/index/styled";
import { connect } from "react-redux";
// import { withRouter } from "react-router-dom";
import { loadVipHomeSchedularDataAsync } from "@/components/main/index/actionCreator";

class BotVip extends React.Component {
  constructor() {
    super();
    this.state = {
      botviplistleft: [],
      botviplistright: []
    };
  }
  render() {
    return (
      <div>
        <BotVipSd>
          <div className="botvip_title">
            <span></span>
            <span>VIP+会员尊享权益</span>99元/年
            <span></span>
          </div>
          <div className="botvip_content">
            <div className="botviplistleft">
              <div className="botvip_count">专属票价</div>
              {this.state.botviplistleft.map((item, index) => (
                <div className="botvip_list" key={index}>
                  <img src={item.pic} alt="" />
                  <p>
                    ￥{item.fixed_price}
                    <span>￥{item.price}</span>
                  </p>
                </div>
              ))}
            </div>
            <div className="botviplistright">
              <div className="botvip_down">专项折扣</div>
              {this.state.botviplistright.map((item, index) => (
                <div className="botvip_show" key={index}>
                  <img src={item.pic} alt="" />
                  <p>
                    {item.min_discount}
                    <span>折</span>
                  </p>
                </div>
              ))}
            </div>
          </div>
        </BotVipSd>
      </div>
    );
  }
  componentDidMount() {
    loadVipHomeSchedularDataAsync(res => {
      var data = res.val.allList;
      var list = [];
      var botviplistleft = [];
      var botviplistright = [];
      for (var n in data) {
        list.push(data[n]);
      }
      botviplistleft.push(list[0]);
      botviplistleft.push(list[1]);
      botviplistright.push(list[2]);
      this.setState({ botviplistleft });
      this.setState({ botviplistright });
    });
  }
}
const mapStateToProps = state => {
  return {};
};
const mapDispatchToProps = dispatch => {
  return {};
};
export default connect(mapStateToProps, mapDispatchToProps)(BotVip);
